package com.cos.lession54.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author: COS
 * @time: 2022/3/9 9:02
 * @description:
 */
@Controller
@RequestMapping("/demo")
public class DemoController {
    @RequestMapping("/d1/{name}")
    public String demo1(@PathVariable String name){
        System.out.println(name);
        System.out.println("这个是demo1");
        //要去的前端页面的名字
        return "index";
    }

    @RequestMapping("/d2")
    public String demo2(){
        System.out.println("这个是demo2");
        //手动设置转发,这个方式一般不使用,除非是要转发到自身其他controller
        return "forward:/demo.jsp";
    }
    @RequestMapping("/d3")
    public String demo3(){
        System.out.println("这个是demo3 在使用重定向");
        return "redirect:/demo.jsp";
    }

}
